let userInfoHistory=uni.getStorageSync('userInfo')||{}
let state={
		hasLogin:Boolean(Object.keys(userInfoHistory).length),
		info:userInfoHistory
   },
   getters={
	   info(state){
		   return state.info
	   },
	   hasLogin(state){
		   return state.hasLogin
	   }
   },
   mutations={
	   login(state,info){
		   console.log(state,info) // 元数据和新数据
		   // 原有数据
		   let _info=state.info
		   // 设置为全局
		   // state.info=info.userInfo
		   state.info = Object.assign({}, _info, info);
		   state.hasLogin=true
		   console.log('state',state)
		   // 保存信息到本地
		   uni.setStorageSync('userInfo',state.info)
		   uni.setStorageSync('uni_id_token',state.info.token)
		   uni.setStorageSync('uni_id_token_expired',state.info.tokenExpired)
	   },
	   logout(state){
		   state.info={},
		   state.hasLogin=false
		   uni.setStorageSync('userInfo',{})
		   uni.setStorageSync('uni_id_token','')
		   uni.setStorageSync('uni_id_token_expired',0)
	   }
   },
   actions={}
export default {
	namespaced:true,
	state,
	getters,
	mutations,
	actions,
}
